﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace DisplayTimeUpgraded
{
    class Program
    {
        static void Main(string[] args)
        {
            int hours, minutes, seconds;

            hours = GetHours();
            if (hours < 0)
            {
                return;
            }

            minutes = GetMinutes();
            if (minutes < 0 )
            {
                return;
            }

            seconds = GetSeconds();
            if (seconds < 0)
            {
                return;
            }


            for (;;)
            {
                Console.WriteLine("{0:00}:{1:00}:{2:00}", hours, minutes, seconds);
                seconds++;

                Thread.Sleep(1000);
                Console.Clear();

                if (seconds == 60)
                {
                    seconds = 0;
                }
                if (seconds == 0)
                {
                    minutes++;
                }
                if (minutes == 60)
                {
                    minutes = 0;
                    hours++;
                }

                if (hours == 24)
                {
                    hours = 0;
                }
            }
        }

        static int GetHours()
        {
            Console.WriteLine("Please, input time (hours):");
            int hours = Convert.ToInt32(Console.ReadLine());
            if (0 < hours || hours > 23)
            {
                Console.WriteLine("Invalid time format");
                return -1;
            }
            return hours;
        }

        static int GetMinutes()
        {
            Console.WriteLine("Please, input time (minutes):");
            int minutes = Convert.ToInt32(Console.ReadLine());
            if (minutes < 0 || minutes > 59)
            {
                Console.WriteLine("Invalid time format");
                return -1;
            }
            return minutes;
        }

        static int GetSeconds()
        {
            Console.WriteLine("Please, input time (seconds):");
            int seconds = Convert.ToInt32(Console.ReadLine());
            if (seconds < 0 || seconds > 23)
            {
                Console.WriteLine("Invalid time format");
                return -1;
            }
            return seconds;
        }
    }
}


